algalcommand.alpha
Class GUIHelper

java.lang.Object
  extended by algalcommand.alpha.GUIHelper

public abstract class GUIHelper
extends java.lang.Object

A bunch of useful methods for generating UI components


Constructor Summary
GUIHelper()
           
 
Method Summary
static void listenToEventsOf(java.lang.Object l, javax.swing.JComponent... comps)
          Add l as a listener to all JComponents provided that support various listeners (as determined by the presence of a add...Listener(ActionListener) method.

Supported Listeners: ActionListener ChangeListener FocusListener ItemListener PopupMenuListener UndoableEditListener

static javax.swing.JPanel makeEditorPanel(java.lang.String label, java.lang.Object variable, java.lang.Object listener)
          A convenience method for generating an editor panel for a variable.
static javax.swing.JFrame makeProgressPopup(java.lang.String title, java.lang.String message, int startvalue, int endvalue, javax.swing.JProgressBar bar)
          Convenience method to create a JFrame with a progress bar inside.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GUIHelper

public GUIHelper()
Method Detail

listenToEventsOf

public static void listenToEventsOf(java.lang.Object l,
                                    javax.swing.JComponent... comps)
Add l as a listener to all JComponents provided that support various listeners (as determined by the presence of a add...Listener(ActionListener) method.

Supported Listeners:

  1. ActionListener
  2. ChangeListener
  3. FocusListener
  4. ItemListener
  5. PopupMenuListener
  6. UndoableEditListener

Parameters:
l - A Listener (e.g. ActionListener) that you want to register with the JComponents
comps - A list of JComponents

makeEditorPanel

public static javax.swing.JPanel makeEditorPanel(java.lang.String label,
                                                 java.lang.Object variable,
                                                 java.lang.Object listener)
A convenience method for generating an editor panel for a variable.
Example:
JFrame frame = new JFrame();
Double altitude;
frame.getContentPane().add(makeEditorPanel("Mountain Peak Altitude (ft)",
  altitude, new ActionListener(){
     public void actionPerformed(ActionEvent ae){
      this.updateAltitude(((JSpinner)ae.getSource()).getValue());
    }
  });
frame.pack();
frame.setVisible(true);

Parameters:
label - The label for the variable.
variable - An object that will be displayed and edited
listener - A listener to handle events generated by editing the variable, or null.
Returns:
A JPanel with a label followed by some sort of editor appropriate for variable (e.g. a JSpinner is variable is a number or a JTextField if variable is a String).
Throws:
java.lang.IllegalArgumentException - If an appropriate editor for variable was not found.

makeProgressPopup

public static javax.swing.JFrame makeProgressPopup(java.lang.String title,
                                                   java.lang.String message,
                                                   int startvalue,
                                                   int endvalue,
                                                   javax.swing.JProgressBar bar)
Convenience method to create a JFrame with a progress bar inside. It may or may not be visible when this method returns the JFrame. if endvalue is less than of equal to startvalue, then the progress bar will be indeterminate.

Parameters:
title -
message -
startvalue -
endvalue -
bar - A JProgressBar, which will be configured by this method
Returns: